import { SpinLoading, ErrorBlock, Button } from 'antd-mobile'
import style from './index.module.scss'
import PropTypes from 'prop-types'

const Loading = (props: {loadingCode: number}) => {
  return (
    <div className={style.loading}>
      {
        props.loadingCode === 1  
        ? <div style={{ color: '#1677ff', fontSize: '15px' }}>
            <SpinLoading color='primary' /> 
          </div>
        : <ErrorBlock status='disconnected' description={
            <Button color='primary' size='small' onClick={() => window.location.reload()}>重新加载</Button>
          }/>
      }  
    </div>
  )
}

export default Loading

Loading.propTypes = {
  loadingCode: PropTypes.number.isRequired
}